/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-26 15:06:47
 * @LastEditTime : 2023-07-30 15:17:09
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\EngineeringListDateStat.jsx
 * @Description  :
 */

import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import {
    AddDataButton,
    ModDataButton,
    DelDataButton,
    ExecuteButton,
    OpenExcelButton,
    SelectExcelButton,
} from '../Common/options'

import { project } from '../../../Data'
const { hostname } = window.location
const { client_id } = project[hostname]
const out = ['bada', 'jtgj']
export const EngineeringListDateStat = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        type: '形象进度',
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            !out.includes(client_id) && (
                <SelectExcelButton
                    key="one"
                    title="下载统计信息"
                    OptionsEvent={OptionsEvent}
                    api={API_LIST()['getEngineeringListDateStatExcel']}
                />
            ),
            !out.includes(client_id) && (
                <OpenExcelButton
                    key="two"
                    title="批量导入"
                    OptionsEvent={OptionsEvent}
                    data={{
                        save: true,
                        submit: true,
                        url: 'getEngineeringListInfo',
                        pos: 'posUploadEngineeringListDateStat',
                    }}
                />
            ),
            Permission?.findIndex(v => v.uuid === 'b8d6a26f-198a-4982-a5be-2af6003b3b9d') !== -1 && (
                <AddDataButton
                    OptionsEvent={OptionsEvent}
                    url={url}
                    type="primary"
                    icon="add"
                    title="新增形象进度日统计"
                />
            ),
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.SearchSort, selectType: 'EngineeringListDateStat' },
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization },
            {
                dataIndex: 'statDate',
                title: '日期',
                valueType: 'Date',
                rules: true,
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'engineeringListUuid',
                title: '形象进度',
                valueType: 'select',
                valueEnum: ClientData.engineeringList,
                rules: true,
                width: 250,
            },
            {
                dataIndex: 'amount',
                title: '工程量',
                valueType: 'inputNumber',
                rules: true,
                width: 100,
                hideInSearch: true,
            },
            {
                dataIndex: 'unit',
                title: '单位',
                valueType: 'input',
                width: 100,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                dataIndex: 'remark',
                title: '备注',
                valueType: 'input',
                width: 100,
            },

            {
                ...commonTableList.isEnabled,
                title: '锁定状态',
                valueEnum: { 0: '未锁定', 1: '已锁定' },
            },
            commonTableList.BeginStatDate,
            commonTableList.EndStatDate,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { isEnabled, uuid } = record
                    return [
                        isEnabled !== 1 &&
                            Permission.findIndex(v => v.uuid === 'f83ede5a-45a3-4ae0-a9fd-f2d2d9ac64fc') !== -1 && (
                                <ModDataButton
                                    OptionsEvent={OptionsEvent}
                                    key="modify"
                                    title="修改"
                                    url={url}
                                    data={record}
                                />
                            ),
                        isEnabled !== 1 &&
                            Permission.findIndex(v => v.uuid === 'c0885e99-3b0e-4901-ac38-b71b85b57f00') !== -1 && (
                                <DelDataButton
                                    OptionsEvent={OptionsEvent}
                                    key="delete"
                                    title="删除"
                                    url={url}
                                    uuid={record.uuid}
                                />
                            ),
                        isEnabled === 1 ? (
                            <ExecuteButton
                                actionRef={actionRef}
                                key="one"
                                title="解锁"
                                data={{ ...record, isEnabled: 0 }}
                                url={`put${url}`}
                                path={[uuid]}
                                tips="数据已解锁!"
                            />
                        ) : (
                            <ExecuteButton
                                actionRef={actionRef}
                                key="two"
                                title="锁定"
                                data={{ ...record, isEnabled: 1 }}
                                url={`put${url}`}
                                path={[uuid]}
                                tips="数据已锁定!"
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
